package com.yanboo.generator.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.yanboo.common.base.BaseEntity;
import com.yanboo.generator.constant.DbType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import jakarta.persistence.*;
import java.io.Serializable;

@Getter
@Setter
@Entity
@DynamicInsert
@DynamicUpdate
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "database_type_map")
    public class DatabaseTypeMap extends BaseEntity implements Serializable {

        private String typeName;

        @Enumerated(value = EnumType.STRING)
        private DbType dbType;

        private String dbColType;

        private String javaFieldType;

        public void copy(com.yanboo.generator.domain.DatabaseTypeMap source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
